package com.tx.consumer;

import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

/**
 * spring-队列-消费者
 */
@Service
public class QueueConsumer {

    @Autowired
    JmsTemplate jmsTemplate;

    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        QueueConsumer consumer = (QueueConsumer)ac.getBean("queueConsumer");
        String msg = (String)consumer.jmsTemplate.receiveAndConvert();
        System.out.println(msg);
    }
}